<template>
	<view class="index">
		<!-- #ifdef APP-PLUS -->
		<!-- <view class="zhiwen" v-show="result!=='成功'">
		</view> -->
		<!-- #endif -->
		
		<!-- 轮播图 -->
		<skeleton :loading="loading" :imgTitle="imgTitle">
			<index-swiper :list="imgArray" @imgload="imgload"></index-swiper>
		</skeleton>
		
		<!-- 通知栏 -->
		<!-- <skeleton :showTitle="showtitle" titleWidth="100%" :showAvatar="false" :row="0"> -->
		<uni-notice-bar @getmore="getmore" showIcon="true" background-color="#fff" color="#000" moreColor="#000"
			:showGetMore="true"  single="true" text="下单请提前1-2天"></uni-notice-bar>
		<!-- </skeleton> -->

		<flower-recommend :recommend="recommedList"></flower-recommend>

	</view>
</template>

<script>
	let _this
	import indexSwiper from '../../components/indexcpns/indexSwiper.vue'
	import flowerRecommend from '../../components/indexcpns/flowerRecommend.vue'
	import Skeleton from '../../components/J-skeleton/J-skeleton.vue'
	import badgeMix from "../../mixin/tabbar-badge.js";
	export default {
		mixins: [badgeMix],
		data() {
			return {
				loading: true,
				imgTitle: true,
				showtitle: true,
				imgArray: [],
				recommedList: [],
				result: ''
			}
		},
		components: {
			indexSwiper,
			flowerRecommend,
			Skeleton
		},
		mounted() {
		_this=this	
		},
		onLoad() {
			this.getSwiperList()
			this.getRecommend()
			this.getscreenHeight()
			// this.checkIsSupportSoterAuthentication()
		},
		methods: {
			getscreenHeight() {
				let res = uni.getSystemInfoSync()
				// console.log(res)
				// this.screenHeight = res.screenHeight - res.windowTop - res.statusBarHeight - 100
			},
			imgload() {},
			getSwiperList() {
				uni.$http.get("/product-server/api/banner/v1/list").then(res => {
					this.imgArray = res.data.data
					this.loading = false
					this.showtitle = false
				}).catch(res=>{
					console.log(res)
					uni.$showMsg('请求失败')
				})
			},
			getmore() {},
			getRecommend() {
				uni.$http.get('/product-server/api/product/v1/promotion').then(res => {
					this.recommedList = res.data.data
					// console.log(this.recommedList)
				})
			},
			checkIsSupportSoterAuthentication() {
				// #ifdef APP-PLUS || MP-WEIXIN
				uni.checkIsSupportSoterAuthentication({
					success(res) {
						console.log(res);
						// 如果当前设备支持生物识别方式，且支持指纹识别方式
						if (res.supportMode && res.supportMode.includes('fingerPrint')) {
							/** 
							 * uni.checkIsSoterEnrolledInDevice : 获取设备内是否录入指纹信息
							 *  checkAuthMode: 'fingerPrint', // 检验指纹信息
							 * */
							uni.checkIsSoterEnrolledInDevice({
								checkAuthMode: 'fingerPrint', // 检验指纹信息
								success(res) {
									console.log(res.isEnrolled)
									if (res.isEnrolled == true) {
										/** 
										 * 开始 SOTER 生物认证
										 * 执行成功，进行后续操作
										 * */
										uni.startSoterAuthentication({
											requestAuthModes: ['fingerPrint'],
											challenge: '123456',
											authContent: '请用指纹解锁',
											success(res) {
												_this.result='成功'
												console.log(res);
												uni.showToast({
													title: "识别成功",
													duration: 5000,
													icon: 'none'
												})
												//指纹识别成功后，进行后续工作
											},
											fail(err) {
												console.log(err, '66666666666666666');
											},
											complete(res) {
												console.log(res);
											}
										})
									} else {
										_this.result = '此设备未录入指纹，请到设置中开启';
									}
								},
								fail(err) {
									uni.showModal({
										title: '温馨提示',
										content: '此设备未录入指纹，请到设置中开启',
										showCancel: false,
										success: function(res) {
											// 进行后续逻辑
										}
									})
								}
							})
						} else {
							_this.result = "此设备不支持指纹识别功能"
						}
					},
					fail(err) {
						uni.showModal({
							title: '温馨提示',
							content: '此设备不支持指纹识别功能',
							showCancel: false,
							success: function(res) {
								// 进行后续逻辑
							}
						})
					}
				})
				// #endif

				// #ifndef APP-PLUS || MP-WEIXIN
				this.result = '此平台不支持指纹识别';
				// #endif
			}


		}
	}
</script>

<style scoped>
	.index>>>.uniui-sound::before {
		content: "\e684" !important;
		color: #ff5400 !important;
	}
	.index{
		padding-bottom: 1rpx;
	}
	.zhiwen{
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		background-color: #e4e4e4;
		z-index: 999;
	}
</style>
